<?php
namespace Payment;
use Doctrine\Common\Util\Inflector;
class PaymentTypes{
    /**
     * @static
     * @return TypeInvoiceIn
     */
    public static function getTypeInvoiceIn(){return new TypeInvoiceIn;}

    /**
     * @static
     * @return TypePayment
     */
    public static function getTypePayment(){return new TypePayment;}

    /**
     * @static
     * @return TypeSmsInvoice
     */
    public static function getTypeSmsInvoice(){return new TypeSmsInvoice;}

    /**
     * @static
     * @return TypeInvoiceItem
     */
    public static function getTypeInvoiceItem(){return new TypeInvoiceItem;}
}

class TypeInvoiceIn extends AbstractType{
    /**
     * @var int
     */
    public $_customerId = null;

    /**
     * @var float
     */
    public $_sum = null;

    /**
     * @var string
     */
    public $_description = null;

    /**
     * @var string
     */
    public $_smsText = null;

    /**
     * @var string
     */
    public $_number = null;

    /**
     * @var array
     */
    public $_items = null;

    public function setCustomerId($customerId) {
        $this->_customerId = $customerId;
    }

    public function getCustomerId() {
        return $this->_customerId;
    }

    public function setDescription($description) {
        $this->_description = $description;
    }

    public function getDescription() {
        return $this->_description;
    }

    public function setItems($items) {
        $this->_items = $items;
    }

    public function getItems() {
        return $this->_items;
    }

    public function setNumber($number) {
        $this->_number = $number;
    }

    public function getNumber() {
        return $this->_number;
    }

    public function setSmsText($smsText) {
        $this->_smsText = $smsText;
    }

    public function getSmsText() {
        return $this->_smsText;
    }

    public function setSum($sum) {
        $this->_sum = $sum;
    }

    public function getSum() {
        return $this->_sum;
    }
}

class TypePayment extends AbstractType{
    public $_paymentId = null;
    public $_invoiceId = null;
    public $_paidSum = null;
    public $_paidDate = null;
    public $_paymentType = null;
    public $_note = null;
    public $_number = null;

    public function setInvoiceId($invoiceId) {
        $this->_invoiceId = $invoiceId;
    }

    public function getInvoiceId() {
        return $this->_invoiceId;
    }

    public function setNote($note) {
        $this->_note = $note;
    }

    public function getNote() {
        return $this->_note;
    }

    public function setNumber($number) {
        $this->_number = $number;
    }

    public function getNumber() {
        return $this->_number;
    }

    public function setPaidDate($paidDate) {
        $this->_paidDate = $paidDate;
    }

    public function getPaidDate() {
        return $this->_paidDate;
    }

    public function setPaidSum($paidSum) {
        $this->_paidSum = $paidSum;
    }

    public function getPaidSum() {
        return $this->_paidSum;
    }

    public function setPaymentId($paymentId) {
        $this->_paymentId = $paymentId;
    }

    public function getPaymentId() {
        return $this->_paymentId;
    }

    public function setPaymentType($paymentType) {
        $this->_paymentType = $paymentType;
    }

    public function getPaymentType() {
        return $this->_paymentType;
    }
}

class TypeSmsInvoice extends AbstractType{
    public $_message = null;
    public $_invoiceId = null;

    public function setInvoiceId($invoiceId) {
        $this->_invoiceId = $invoiceId;
    }

    public function getInvoiceId() {
        return $this->_invoiceId;
    }

    public function setMessage($message) {
        $this->_message = $message;
    }

    public function getMessage() {
        return $this->_message;
    }
}

class TypeInvoiceItem extends AbstractType{
    public $_count = null;
    public $_price = null;
    public $_description = null;

    public function setCount($count) {
        $this->_count = $count;
    }

    public function getCount() {
        return $this->_count;
    }

    public function setDescription($description) {
        $this->_description = $description;
    }

    public function getDescription() {
        return $this->_description;
    }

    public function setPrice($price) {
        $this->_price = $price;
    }

    public function getPrice() {
        return $this->_price;
    }
}

class AbstractType{
    /**
     * @return \stdClass
     */
    public function get(){
        $result = new \stdClass();
        foreach($this as $key=>$value){
            if(null === $value) continue;
            $propName = Inflector::tableize(str_replace('_', '', $key));
            $result->$propName = $value;
        }
        return $result;
    }
    /**
     * @param  $data
     * @return bool
     */
    public function set($data){
        if(is_array($data) && !empty($data)){
            foreach ($data as $key=>$value){
                $funcname = 'set'.Inflector::classify($key);
                $this->$funcname($value);
            }
            return true;
        }

        return false;
    }
}